import java.util.Stack;

class CQueue {
    Stack<Integer> A, B;

    public CQueue() {
        A = new Stack<>();
        B = new Stack<>();
    }

    public void appendTail(int value) {
        A.push(value);
    }

    public int deleteHead() {
        if (B.isEmpty() && A.isEmpty()) return -1;
        if (!B.isEmpty()) return B.pop();
        while (!A.isEmpty()) {
            B.push(A.pop());
        }
        return B.pop();
    }
}